/**
 * @ProjectName: ShopSytem
 * @Title: GoodClassList.java 
 * @Package com.element5th.shop.servlet.good 
 * @Description: 得到商品种类列表
 * @author 第五元素小组   
 * @date 2012-10-26 16:50:15 
 * @version V1.0   
 */
package com.element5th.shop.servlet.good;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.element5th.shop.dao.good.GoodDaoImpl;
import com.element5th.shop.dao.good.IGoodDao;
import com.element5th.shop.dto.BaseDto;

/**
 * Servlet implementation class GetGoodClassList
 */
@WebServlet("/good_classList")
public class GoodClassList extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		List<BaseDto> dtoClassList = new ArrayList<BaseDto>();
		List<BaseDto> dtoShopList = new ArrayList<BaseDto>();
		IGoodDao dao = new GoodDaoImpl();
		dtoClassList = dao.goodClassList();

		PrintWriter writer = response.getWriter();
		for (int i = 0; i < dtoClassList.size(); i++) {

			dtoShopList = dao.getShowGoodList(dtoClassList.get(i));

			writer.print("<div class='d7'><div class='d7_boder'><div class='c_d7_type'><span id='"
					+ dtoClassList.get(i).getGoodBigClass().getBigclassName()
					+ "'>"
					+ dtoClassList.get(i).getGoodBigClass().getBigclassName()
					+ "</span></div><div class='c_d7_1'><ul>");
			for (int j = 0; j < dtoClassList.get(i).getGoodBigClass()
					.getGoodClasses().size(); j++) {
				writer.print("<li><a href='page/good_list?classId="
						+dtoClassList.get(i).getGoodBigClass()
								.getGoodClasses().get(j).getClassId()
						+"&className="+dtoClassList.get(i).getGoodBigClass()
						.getGoodClasses().get(j).getClassName()+ "&bigClassName="+
						dtoClassList.get(i).getGoodBigClass().getBigclassName()+"'>"
						+ dtoClassList.get(i).getGoodBigClass()
								.getGoodClasses().get(j).getClassName()
						+ "</a></li>");
			}
			writer.print("</ul></div><img src='images/product_" + (i + 1)
					+ ".jpg' alt='' /></div><div class='c_d7_2'><ul>");
			for (int j = 0; j < dtoShopList.size(); j++) {
				
				writer.print("<li class='good_list_li'><a href=''><img src='images/goodPic/toppic/"
						+ dtoShopList.get(j).getGoodDetail().getDetailToppic()
						+ "' /> </a> <a class='good_a_text' href=''>"
						+ dtoShopList.get(j).getGoodDetail().getDetailTitle()
						+ "</a><div class='div_price_1'><span class='div_price_s'>五折价:</span> <span class='good_price'>￥"
						+ dtoShopList.get(j).getShopGood().getGoodPrice()
						+ "</span></div></li>");

			}
			writer.print("</ul></div></div>");
		}
	}
}
